package com.yikaiye.android.yikaiye.utils;

import android.content.Context;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.yikaiye.android.yikaiye.R;

public class UiUtils {

    /**
     * 获取经营状态
     */
    public static String getManagementStatus(String state) {
        String result;
        switch (state) {
            case "1":
                result = "存续";
                break;
            case "2":
                result = "注销";
                break;
            case "3":
                result = "吊销";
                break;
            case "4":
                result = "撤销";
                break;
            case "5":
                result = "迁出";
                break;
            case "6":
                result = "设立中";
                break;
            case "7":
                result = "清算中";
                break;
            case "8":
                result = "停业";
                break;
            case "9":
            default:
                result = "其他";
                break;
        }
        return result;
    }

    /**
     * 获取经营状态背景
     */
    public static void setManagementStatusColor(Context context, TextView tv, String state) {
        switch (state) {
            case "1": // 存续
                tv.setTextColor(ContextCompat.getColor(context, R.color.color_46b39e));
                tv.setBackgroundResource(R.drawable.shape_stroke_6646b39e_2dp);
                break;
            case "3": // 吊销
                tv.setTextColor(ContextCompat.getColor(context, R.color.color_ff8c91));
                tv.setBackgroundResource(R.drawable.shape_stroke_66ff8c91_2dp);
                break;
            case "2": // 注销
            case "4": // 撤销
            case "5": // 迁出
            case "6": // 设立中
            case "7": // 清算中
            case "8": // 停业
            case "9": // 其他
            default:
                tv.setTextColor(ContextCompat.getColor(context, R.color.color_9b9b9b));
                tv.setBackgroundResource(R.drawable.shape_stroke_669b9b9b_2dp);
                break;
        }
    }

    /**
     * 服务状态：0.待办 1.在办 2.暂停 3.已办结 4.已终止
     */
    public static void setServiceStatus(int state, TextView statusTv, Context context) {
        switch (state) {
            case 0:
                statusTv.setText(context.getString(R.string.wait_work));
                statusTv.setTextColor(ContextCompat.getColor(context, R.color.color_3b3a40));
                break;
            case 1:
                statusTv.setText(context.getString(R.string.working));
                statusTv.setTextColor(ContextCompat.getColor(context, R.color.color_f93f50));
                break;
            case 2:
                statusTv.setText(context.getString(R.string.pause));
                statusTv.setTextColor(ContextCompat.getColor(context, R.color.color_ff8c30));
                break;
            case 3:
                statusTv.setText(context.getString(R.string.already_work_finish));
                statusTv.setTextColor(ContextCompat.getColor(context, R.color.color_929292));
                break;
            case 4:
                statusTv.setText(context.getString(R.string.already_complete));
                statusTv.setTextColor(ContextCompat.getColor(context, R.color.color_ff9b9b));
                break;
            default:
                statusTv.setText("");
                break;
        }
    }

    /**
     * 开票状态
     */
    public static String getInvoiceStatus(int state) {
        String result;
        switch (state) {
            case 0:
                result = "待审核";
                break;
            case 1:
                result = "已审核";
                break;
            case 2:
                result = "已开票";
                break;
            case 3:
                result = "已红冲";
                break;
            case 4:
                result = "已作废";
                break;
            default:
                result = "其他";
                break;
        }
        return result;
    }
}
